import React, { useState, useEffect } from "react";
import Taro, { getCurrentInstance } from "@tarojs/taro";
import { View, Text } from "@tarojs/components";
import List from "../../../component/List";
import { getConcernedInfo } from "./api.js";

export default function index() {
  const { id } = getCurrentInstance().router.params;
  const [list, setList] = useState([]);
  useEffect(() => {
    getConcernedInfo(id).then((res) => {
      if (res.code === 200) {
        setList(res.data);
      }
    })
  }, []);
  const detail = (userId) => {
    Taro.navigateTo({ url: `../detail/index?userId=${userId}`})
    // Taro.navigateTo({ url: `my/detail/index?userId=${userId}` })
  }
  return (
    <View>
        {list.map((item) => {
          return (
            <View onClick={() => detail(item.id)} key={item.id}>
              <List  {...item} />
            </View>
          )
        })}
    </View>
  )
}
